﻿namespace WMS6.SQLServerDAL
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Data.Common;
    using System.Data.SqlClient;
    using System.Text;
    using WMS6.Common;
    using WMS6.DataEntity;
    using WMS6.DBUtility;
    using WMS6.IDAL;
    using WMS6.QueryEntity;

    public class XordersDA : IXordersDA
    {
        private string APPORTION = "@APPORTION";
        private string CONSIGNEE_ID = "@CONSIGNEE_ID";
        private string CREATED_BY = "@CREATED_BY";
        private string DELIVERY_DATE = "@DELIVERY_DATE";
        private string DOOR = "@DOOR";
        private string EXTERN_ORDER_ID = "@EXTERN_ORDER_ID";
        private string EXTERNAL_LOAD_ID = "@EXTERNAL_LOAD_ID";
        private string IS_ACTIVE = "@IS_ACTIVE";
        private string LOAD_ID = "@LOAD_ID";
        private string OH_TYPE = "@OH_TYPE";
        private string ORDER_ID = "@ORDER_ID";
        private string ORDER_TYPE = "@ORDER_TYPE";
        private string OWNER_ID = "@OWNER_ID";
        private string PO_ID = "@PO_ID";
        private string ROUTE = "@ROUTE";
        private string SQL_CHECK_XORDERS_ID_UNIQUE = " SELECT COUNT(1) FROM @_@XORDERS WHERE ORDER_ID = @ORDER_ID ";
        private string SQL_DELETE_XORDERS = " DELETE FROM @_@XORDERS WHERE ORDER_ID = @ORDER_ID ";
        private string SQL_INSERT_XORDERS = " INSERT INTO @_@XORDERS ( WH_ID, ORDER_ID, EXTERN_ORDER_ID, ORDER_TYPE, OWNER_ID, PO_ID, STATUS, LOAD_ID, ROUTE, DOOR, STOP, EXTERNAL_LOAD_ID, DELIVERY_DATE, OH_TYPE, VEHICLE_CARRIER, APPORTION, CONSIGNEE_ID, IS_ACTIVE, CREATED_BY, CREATED_DATE, UPDATED_BY, UPDATED_DATE) VALUES ( @WH_ID, @ORDER_ID, @EXTERN_ORDER_ID, @ORDER_TYPE, @OWNER_ID, @PO_ID, @STATUS, @LOAD_ID, @ROUTE, @DOOR, @STOP, @EXTERNAL_LOAD_ID, @DELIVERY_DATE, @OH_TYPE, @VEHICLE_CARRIER, @APPORTION, @CONSIGNEE_ID, @IS_ACTIVE, @CREATED_BY, GETDATE(), @UPDATED_BY, GETDATE() )  ";
        private string SQL_SELECT_ALL_XORDERS = " SELECT  ROWID, WH_ID, ORDER_ID, EXTERN_ORDER_ID, ORDER_TYPE, OWNER_ID, PO_ID, STATUS, LOAD_ID, ROUTE, DOOR, STOP, EXTERNAL_LOAD_ID, DELIVERY_DATE, OH_TYPE, VEHICLE_CARRIER, APPORTION, CONSIGNEE_ID, IS_ACTIVE, TS, CREATED_BY, CREATED_DATE, UPDATED_BY, UPDATED_DATE  FROM  @_@XORDERS ";
        private string SQL_UPDATE_XORDERS = " UPDATE @_@XORDERS SET WH_ID = @WH_ID, EXTERN_ORDER_ID = @EXTERN_ORDER_ID, ORDER_TYPE = @ORDER_TYPE, OWNER_ID = @OWNER_ID, PO_ID = @PO_ID, STATUS = @STATUS, LOAD_ID = @LOAD_ID, ROUTE = @ROUTE, DOOR = @DOOR, STOP = @STOP, EXTERNAL_LOAD_ID = @EXTERNAL_LOAD_ID, DELIVERY_DATE = @DELIVERY_DATE, OH_TYPE = @OH_TYPE, VEHICLE_CARRIER = @VEHICLE_CARRIER, APPORTION = @APPORTION, CONSIGNEE_ID = @CONSIGNEE_ID, IS_ACTIVE = @IS_ACTIVE, UPDATED_BY = @UPDATED_BY, UPDATED_DATE = GETDATE() WHERE ORDER_ID = @ORDER_ID  ";
        private string STATUS = "@STATUS";
        private string STOP = "@STOP";
        private string TS = "@TS";
        private string UPDATED_BY = "@UPDATED_BY";
        private string VEHICLE_CARRIER = "@VEHICLE_CARRIER";
        private string WH_ID = "@WH_ID";

        public bool CheckXordersIDUnique(string xordersID, string whLoginID)
        {
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ORDER_ID", xordersID) };
            return (DBHelper.ExecuteScalar(CommandType.Text, this.SQL_CHECK_XORDERS_ID_UNIQUE.Replace("@_@", whLoginID), paras).ToString() == "1");
        }

        public bool CheckXordersIDUnique(DataBase dataBase, DbTransaction tran, string xordersID, string whLoginID)
        {
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ORDER_ID", xordersID) };
            return (dataBase.ExecuteScalar(tran, CommandType.Text, this.SQL_CHECK_XORDERS_ID_UNIQUE.Replace("@_@", whLoginID), paras).ToString() == "1");
        }

        public int DeleteXorders(List<string> xordersID, string whLoginID)
        {
            int result = 0;
            DataBase dataBase = new DataBase();
            DbConnection conn = dataBase.connection;
            conn.Open();
            DbTransaction tran = conn.BeginTransaction();
            try
            {
                for (int j = 0; j < xordersID.Count; j++)
                {
                    SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ORDER_ID", xordersID[j]) };
                    result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_DELETE_XORDERS.Replace("@_@", whLoginID), paras);
                }
                tran.Commit();
            }
            catch (SqlException sqlEx)
            {
                tran.Rollback();
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            finally
            {
                conn.Close();
            }
            return result;
        }

        public int DeleteXorders(DataBase dataBase, DbTransaction tran, List<string> xordersID, string whLoginID)
        {
            int result = 0;
            try
            {
                for (int j = 0; j < xordersID.Count; j++)
                {
                    SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ORDER_ID", xordersID[j]) };
                    result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_DELETE_XORDERS.Replace("@_@", whLoginID), paras);
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }

        public DataSet GetAllXorders(string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_XORDERS.Replace("@_@", whLoginID);
            return DBHelper.ExecuteDataSet(CommandType.Text, sql);
        }

        public DataSet GetAllXorders(DataBase dataBase, DbTransaction tran, string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_XORDERS.Replace("@_@", whLoginID);
            return dataBase.ExecuteDataSet(tran, CommandType.Text, sql);
        }

        public XordersInfo GetXordersByID(string xordersID, string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_XORDERS.Replace("@_@", whLoginID) + " WHERE ORDER_ID = @ORDER_ID  ";
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ORDER_ID", xordersID) };
            XordersInfo xordersInfo = null;
            using (IDataReader reader = DBHelper.ExecuteReader(CommandType.Text, sql, paras))
            {
                if (reader.Read())
                {
                    DateTime CS00003;
                    xordersInfo = new XordersInfo((reader["ROWID"].ToString() != "") ? int.Parse(reader["ROWID"].ToString()) : 0, reader["WH_ID"].ToString(), reader["ORDER_ID"].ToString(), reader["EXTERN_ORDER_ID"].ToString(), reader["ORDER_TYPE"].ToString(), reader["OWNER_ID"].ToString(), reader["PO_ID"].ToString(), reader["STATUS"].ToString(), reader["LOAD_ID"].ToString(), reader["ROUTE"].ToString(), reader["DOOR"].ToString(), reader["STOP"].ToString(), reader["EXTERNAL_LOAD_ID"].ToString(), (reader["DELIVERY_DATE"].ToString() != "") ? DateTime.Parse(reader["DELIVERY_DATE"].ToString()) : (CS00003 = new DateTime()), reader["OH_TYPE"].ToString(), reader["VEHICLE_CARRIER"].ToString(), reader["APPORTION"].ToString(), reader["CONSIGNEE_ID"].ToString(), reader["IS_ACTIVE"].ToString(), (byte[]) reader["TS"], reader["CREATED_BY"].ToString(), (reader["CREATED_DATE"].ToString() != "") ? DateTime.Parse(reader["CREATED_DATE"].ToString()) : (CS00003 = new DateTime()), reader["UPDATED_BY"].ToString(), (reader["UPDATED_DATE"].ToString() != "") ? DateTime.Parse(reader["UPDATED_DATE"].ToString()) : new DateTime());
                }
            }
            return xordersInfo;
        }

        public XordersInfo GetXordersByID(DataBase dataBase, DbTransaction tran, string xordersID, string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_XORDERS.Replace("@_@", whLoginID) + " WHERE ORDER_ID = @ORDER_ID  ";
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@ORDER_ID", xordersID) };
            XordersInfo xordersInfo = null;
            IDataReader reader = dataBase.ExecuteReader(tran, CommandType.Text, sql, paras);
            if (reader.Read())
            {
                DateTime CS00003;
                xordersInfo = new XordersInfo((reader["ROWID"].ToString() != "") ? int.Parse(reader["ROWID"].ToString()) : 0, reader["WH_ID"].ToString(), reader["ORDER_ID"].ToString(), reader["EXTERN_ORDER_ID"].ToString(), reader["ORDER_TYPE"].ToString(), reader["OWNER_ID"].ToString(), reader["PO_ID"].ToString(), reader["STATUS"].ToString(), reader["LOAD_ID"].ToString(), reader["ROUTE"].ToString(), reader["DOOR"].ToString(), reader["STOP"].ToString(), reader["EXTERNAL_LOAD_ID"].ToString(), (reader["DELIVERY_DATE"].ToString() != "") ? DateTime.Parse(reader["DELIVERY_DATE"].ToString()) : (CS00003 = new DateTime()), reader["OH_TYPE"].ToString(), reader["VEHICLE_CARRIER"].ToString(), reader["APPORTION"].ToString(), reader["CONSIGNEE_ID"].ToString(), reader["IS_ACTIVE"].ToString(), (byte[]) reader["TS"], reader["CREATED_BY"].ToString(), (reader["CREATED_DATE"].ToString() != "") ? DateTime.Parse(reader["CREATED_DATE"].ToString()) : (CS00003 = new DateTime()), reader["UPDATED_BY"].ToString(), (reader["UPDATED_DATE"].ToString() != "") ? DateTime.Parse(reader["UPDATED_DATE"].ToString()) : new DateTime());
            }
            if (!reader.IsClosed)
            {
                reader.Close();
            }
            return xordersInfo;
        }

        public XordersInfo GetXordersBypoID(DataBase dataBase, DbTransaction tran, string poID, string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_XORDERS.Replace("@_@", whLoginID) + " WHERE PO_ID = @PO_ID  ";
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@PO_ID", poID) };
            XordersInfo xordersInfo = null;
            IDataReader reader = dataBase.ExecuteReader(tran, CommandType.Text, sql, paras);
            if (reader.Read())
            {
                DateTime CS00003;
                xordersInfo = new XordersInfo((reader["ROWID"].ToString() != "") ? int.Parse(reader["ROWID"].ToString()) : 0, reader["WH_ID"].ToString(), reader["ORDER_ID"].ToString(), reader["EXTERN_ORDER_ID"].ToString(), reader["ORDER_TYPE"].ToString(), reader["OWNER_ID"].ToString(), reader["PO_ID"].ToString(), reader["STATUS"].ToString(), reader["LOAD_ID"].ToString(), reader["ROUTE"].ToString(), reader["DOOR"].ToString(), reader["STOP"].ToString(), reader["EXTERNAL_LOAD_ID"].ToString(), (reader["DELIVERY_DATE"].ToString() != "") ? DateTime.Parse(reader["DELIVERY_DATE"].ToString()) : (CS00003 = new DateTime()), reader["OH_TYPE"].ToString(), reader["VEHICLE_CARRIER"].ToString(), reader["APPORTION"].ToString(), reader["CONSIGNEE_ID"].ToString(), reader["IS_ACTIVE"].ToString(), (byte[]) reader["TS"], reader["CREATED_BY"].ToString(), (reader["CREATED_DATE"].ToString() != "") ? DateTime.Parse(reader["CREATED_DATE"].ToString()) : (CS00003 = new DateTime()), reader["UPDATED_BY"].ToString(), (reader["UPDATED_DATE"].ToString() != "") ? DateTime.Parse(reader["UPDATED_DATE"].ToString()) : new DateTime());
            }
            if (!reader.IsClosed)
            {
                reader.Close();
            }
            return xordersInfo;
        }

        public DataSet GetXordersByQueryList(List<string> sqlWhere, XordersQueryEntity xordersQuery, string whLoginID)
        {
            string temp = this.SQL_SELECT_ALL_XORDERS.Replace("@_@", whLoginID);
            for (int i = 0; i < sqlWhere.Count; i++)
            {
                if (i == 0)
                {
                    temp = temp + " WHERE " + sqlWhere[i].ToString();
                }
                else
                {
                    temp = temp + " AND " + sqlWhere[i].ToString();
                }
            }
            if (!xordersQuery.IsGetAll)
            {
                temp = PagingHelper.GetPagingSQL(temp, xordersQuery.CurrentPage, xordersQuery.PageSize, xordersQuery.SortField, xordersQuery.SortDirection);
            }
            return DBHelper.ExecuteDataSet(CommandType.Text, temp);
        }

        public DataSet GetXordersByQueryList(DataBase dataBase, DbTransaction tran, List<string> sqlWhere, XordersQueryEntity xordersQuery, string whLoginID)
        {
            string temp = this.SQL_SELECT_ALL_XORDERS.Replace("@_@", whLoginID);
            for (int i = 0; i < sqlWhere.Count; i++)
            {
                if (i == 0)
                {
                    temp = temp + " WHERE " + sqlWhere[i].ToString();
                }
                else
                {
                    temp = temp + " AND " + sqlWhere[i].ToString();
                }
            }
            temp = PagingHelper.GetPagingSQL(temp, xordersQuery.CurrentPage, xordersQuery.PageSize, xordersQuery.SortField, xordersQuery.SortDirection);
            return dataBase.ExecuteDataSet(tran, CommandType.Text, temp);
        }

        public DataSet GetXordersReceiptPurchaseOrderByQueryList(List<string> sqlWhere, XordersQueryEntity xordersQueryEntity, string whLoginID)
        {
            string temp = string.Empty;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("   SELECT R.RECEIPT_ID,R.PO_ID,R.OWNER_ID,XO.ORDER_ID FROM @_@RECEIPT R  ");
            strSql.Append("   INNER JOIN @_@PURCHASE_ORDER PO ON R.PO_ID= PO.PO_ID AND  PO_TYPE='FLOWTHRU '");
            strSql.Append("   INNER JOIN @_@XORDERS XO ON PO.PO_ID = XO.PO_ID  AND  PO_TYPE='FLOWTHRU' ");
            for (int i = 0; i < sqlWhere.Count; i++)
            {
                if (i == 0)
                {
                    strSql.Append(" WHERE " + sqlWhere[i].ToString());
                }
                else
                {
                    strSql.Append("  AND " + sqlWhere[i].ToString());
                }
            }
            temp = PagingHelper.GetPagingSQL(strSql.ToString().Replace("@_@", whLoginID), xordersQueryEntity.CurrentPage, xordersQueryEntity.PageSize, xordersQueryEntity.SortField, xordersQueryEntity.SortDirection);
            return DBHelper.ExecuteDataSet(CommandType.Text, temp);
        }

        public int InsertXorders(XordersInfo xordersInfo, string whLoginID)
        {
            int result = 0;
            DataBase db = new DataBase();
            DbConnection conn = db.connection;
            conn.Open();
            DbTransaction tran = conn.BeginTransaction();
            try
            {
                xordersInfo.WhID = whLoginID.Substring(0, whLoginID.Length - 1);
                SqlParameter[] paras = this.Set_Xorders_Parameters(xordersInfo);
                if (paras != null)
                {
                    result += db.ExecuteNonQuery(tran, CommandType.Text, this.SQL_INSERT_XORDERS.Replace("@_@", whLoginID), paras);
                }
                tran.Commit();
            }
            catch (SqlException sqlEx)
            {
                tran.Rollback();
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            finally
            {
                conn.Close();
            }
            return result;
        }

        public int InsertXorders(DataBase dataBase, DbTransaction tran, XordersInfo xordersInfo, string whLoginID)
        {
            int result = 0;
            try
            {
                xordersInfo.WhID = whLoginID.Substring(0, whLoginID.Length - 1);
                SqlParameter[] paras = this.Set_Xorders_Parameters(xordersInfo);
                if (paras != null)
                {
                    result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_INSERT_XORDERS.Replace("@_@", whLoginID), paras);
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }

        private SqlParameter[] Set_Xorders_Parameters(XordersInfo xordersInfo)
        {
            SqlParameter[] paramArray = new SqlParameter[] { 
                new SqlParameter(this.WH_ID, SqlDbType.VarChar, 30), new SqlParameter(this.ORDER_ID, SqlDbType.VarChar, 20), new SqlParameter(this.EXTERN_ORDER_ID, SqlDbType.VarChar, 30), new SqlParameter(this.ORDER_TYPE, SqlDbType.VarChar, 20), new SqlParameter(this.OWNER_ID, SqlDbType.VarChar, 20), new SqlParameter(this.PO_ID, SqlDbType.VarChar, 20), new SqlParameter(this.STATUS, SqlDbType.VarChar, 20), new SqlParameter(this.LOAD_ID, SqlDbType.VarChar, 20), new SqlParameter(this.ROUTE, SqlDbType.VarChar, 20), new SqlParameter(this.DOOR, SqlDbType.VarChar, 20), new SqlParameter(this.STOP, SqlDbType.VarChar, 20), new SqlParameter(this.EXTERNAL_LOAD_ID, SqlDbType.VarChar, 20), new SqlParameter(this.DELIVERY_DATE, SqlDbType.DateTime, 8), new SqlParameter(this.OH_TYPE, SqlDbType.VarChar, 20), new SqlParameter(this.VEHICLE_CARRIER, SqlDbType.VarChar, 30), new SqlParameter(this.APPORTION, SqlDbType.VarChar, 1), 
                new SqlParameter(this.CONSIGNEE_ID, SqlDbType.VarChar, 20), new SqlParameter(this.IS_ACTIVE, SqlDbType.VarChar, 1), new SqlParameter(this.CREATED_BY, SqlDbType.VarChar, 20), new SqlParameter(this.UPDATED_BY, SqlDbType.VarChar, 20)
             };
            if (!string.IsNullOrEmpty(xordersInfo.WhID))
            {
                paramArray[0].Value = xordersInfo.WhID;
            }
            else
            {
                paramArray[0].Value = DBNull.Value;
            }
            paramArray[1].Value = xordersInfo.OrderID;
            if (!string.IsNullOrEmpty(xordersInfo.ExternOrderID))
            {
                paramArray[2].Value = xordersInfo.ExternOrderID;
            }
            else
            {
                paramArray[2].Value = DBNull.Value;
            }
            paramArray[3].Value = xordersInfo.OrderType;
            paramArray[4].Value = xordersInfo.OwnerID;
            paramArray[5].Value = xordersInfo.PoID;
            paramArray[6].Value = xordersInfo.Status;
            if (!string.IsNullOrEmpty(xordersInfo.LoadID))
            {
                paramArray[7].Value = xordersInfo.LoadID;
            }
            else
            {
                paramArray[7].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(xordersInfo.Route))
            {
                paramArray[8].Value = xordersInfo.Route;
            }
            else
            {
                paramArray[8].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(xordersInfo.Door))
            {
                paramArray[9].Value = xordersInfo.Door;
            }
            else
            {
                paramArray[9].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(xordersInfo.Stop))
            {
                paramArray[10].Value = xordersInfo.Stop;
            }
            else
            {
                paramArray[10].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(xordersInfo.ExternalLoadID))
            {
                paramArray[11].Value = xordersInfo.ExternalLoadID;
            }
            else
            {
                paramArray[11].Value = DBNull.Value;
            }
            paramArray[12].Value = xordersInfo.DeliveryDate;
            if (!string.IsNullOrEmpty(xordersInfo.OhType))
            {
                paramArray[13].Value = xordersInfo.OhType;
            }
            else
            {
                paramArray[13].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(xordersInfo.VehicleCarrier))
            {
                paramArray[14].Value = xordersInfo.VehicleCarrier;
            }
            else
            {
                paramArray[14].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(xordersInfo.Apportion))
            {
                paramArray[15].Value = xordersInfo.Apportion;
            }
            else
            {
                paramArray[15].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(xordersInfo.ConsigneeID))
            {
                paramArray[0x10].Value = xordersInfo.ConsigneeID;
            }
            else
            {
                paramArray[0x10].Value = DBNull.Value;
            }
            paramArray[0x11].Value = xordersInfo.IsActive;
            paramArray[0x12].Value = xordersInfo.CreatedBy;
            paramArray[0x13].Value = xordersInfo.UpdatedBy;
            return paramArray;
        }

        public int UpdateXorders(XordersInfo xordersInfo, string whLoginID)
        {
            int result = 0;
            DataBase db = new DataBase();
            DbConnection conn = db.connection;
            conn.Open();
            DbTransaction tran = conn.BeginTransaction();
            try
            {
                xordersInfo.WhID = whLoginID;
                SqlParameter[] paras = this.Set_Xorders_Parameters(xordersInfo);
                if (paras != null)
                {
                    result += db.ExecuteNonQuery(tran, CommandType.Text, this.SQL_UPDATE_XORDERS.Replace("@_@", whLoginID), paras);
                }
                tran.Commit();
            }
            catch (SqlException sqlEx)
            {
                tran.Rollback();
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            finally
            {
                conn.Close();
            }
            return result;
        }

        public int UpdateXorders(DataBase dataBase, DbTransaction tran, XordersInfo xordersInfo, string whLoginID)
        {
            int result = 0;
            try
            {
                xordersInfo.WhID = whLoginID;
                SqlParameter[] paras = this.Set_Xorders_Parameters(xordersInfo);
                if (paras != null)
                {
                    result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_UPDATE_XORDERS.Replace("@_@", whLoginID), paras);
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }

        public int UpdateXordersStatus(DataBase dataBase, DbTransaction tran, string status, string xorderID, string whLoginID, PubParasInfo pubParasInfo)
        {
            int result = 0;
            try
            {
                StringBuilder strSql = new StringBuilder();
                strSql.AppendFormat(" UPDATE {0}XORDERS SET STATUS='{1}',UPDATED_DATE=GETDATE(),UPDATED_BY='{3}' WHERE ORDER_ID='{2}'", new object[] { whLoginID, status, xorderID, pubParasInfo.UserID });
                result += dataBase.ExecuteNonQuery(tran, CommandType.Text, strSql.ToString());
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }
    }
}

